﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
  
     <!-- 增加一个配置  -->
    <script src="../../../Scripts/config.js" type="text/javascript" > </script>
    <script src="../../../Comm/Gener.js" type="text/javascript"></script>

    <link href="../../../Scripts/easyUI/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/easyUI/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="../js/FormDesignerService.js" type="text/javascript"></script>

    <script language="javascript" type="text/javascript">

        //公共方法
        function AjaxServiceGener(param, callback, scope) {
            $.ajax({
                type: "GET", //使用GET或POST方法访问后台
                dataType: "text", //返回json格式的数据
                contentType: "application/json; charset=utf-8",
                url: Handler, //要访问的后台地址
                data: param, //要发送的数据
                async: true,
                cache: false,
                complete: function () { }, //AJAX请求完成时隐藏loading提示
                error: function (XMLHttpRequest, errorThrown) {
                    callback(XMLHttpRequest);
                },
                success: function (msg) {//msg为返回的数据，在这里做数据绑定
                    var data = msg;
                    callback(data, scope);
                }
            });
        }

        //加载grid
        function LoadGridData(pageNumber, pageSize) {
            this.pageNumber = pageNumber;
            this.pageSize = pageSize;

            var params = {
                action: "FrmTable_GetSFTableList",
                pageNumber: pageNumber,
                pageSize: pageSize
            };

            AjaxServiceGener(params, LoadDataGridCallBack, this);
        }

        //初始化
        $(function () {
            LoadGridData(1,8);
        });

        //加载grid后回调函数
        function LoadDataGridCallBack(js, scorp) {

            if (js.indexOf('err@') != -1) {
                alert(js);
                return;
            }

            $("#pageloading").hide();

            var pushData = eval('(' + js + ')');

            $('#newsGrid').datagrid({
                columns: [[
                    { field: 'No', title: '编号', width: 60 },
                    { field: 'Name', title: '名称', width: 90 },
                    { field: 'FK_Val', title: '默认字段', width: 30 },
                    { field: 'FK_SFDBSrcText', title: '数据源', width: 50 },
                    { field: 'SrcTypeText', title: '数据类型', width: 50 }
                ]],
                idField: 'No',
                singleSelect: true,
                data: pushData,
                width: 'auto',
                height: 'auto',
                striped: true,
                rownumbers: true,
                pagination: true,
                fitColumns: true,
                pageNumber: scorp.pageNumber,
                pageSize: scorp.pageSize,
                pageList: [6, 12, 18, 100],
                loadMsg: '数据加载中......',
                onClickRow: function (rowIndex, rowData) {
                    $('#TB_Name').val(rowData["Name"]);
                    $('#TB_KeyOfEn').val(rowData["FK_Val"]);
                    $('#TB_UIBindKey').val(rowData["No"]);
                  //  $('#TB_Vals').val(rowData["CfgVal"]);
                    //执行编辑函数.
                  //  Edit(false);
                }
            });
            //分页
            var pg = $("#newsGrid").datagrid("getPager");
            if (pg) {
                $(pg).pagination({
                    onRefresh: function (pageNumber, pageSize) {
                        LoadGridData(pageNumber, pageSize);
                    },
                    onSelectPage: function (pageNumber, pageSize) {
                        LoadGridData(pageNumber, pageSize);
                    }
                });
            }
        }

        //传入父窗体
        function GetFrmInfo() {
            return {
                Name: $.trim($("#TB_Name").val()),
                KeyOfEn: $.trim($("#TB_KeyOfEn").val()),
                IsCreateLabel: $("#CB_Generate_Tags").prop("checked"),
                UIBindKey: $.trim($("#TB_UIBindKey").val())
            };
        }

        //编辑.
        function Edit() {
            var no = $.trim($("#TB_No").val());

            var url = '../../Comm/En.htm?EnName=BP.Sys.FrmUI.SFTableClass&No=' + no;

            OpenDialogAndCloseRefresh(url, "编辑外键表", 600, 550, "icon-new");
        }

        //新建.
        function New() {
            var url = '../../FoolFormDesigner/SFTable/Default.htm';
            window.location.href = url;
            return;
        }
    </script>
</head>
<body class="easyui-layout">
    <div data-options="region:'center'">
        <div id="tabs" class="easyui-tabs" data-options="fit:true ,border:false">

            <div title="外键、外部数据、webservices数据源." style="width: 600px; height: 900px;">
                <div id="tb" style="padding: 3px;">
                    <input type="button" id="Btn_New" class="easyui-button" onclick="New()" value="新增" />
                    &nbsp;&nbsp;
                    <input type="button" id="Btn_Edit" onclick="Edit(true)" value="编辑" />
                </div>
                
                <table id="newsGrid" toolbar="#tb" class="easyui-datagrid">
                </table>

                <table>
                    <tr>
                        <td colspan="2">
                            <br />
                            中文名：
                            <input id="TB_Name" class="easyui-textbox" style="width: 150px" />
                            字段英文名：<input id="TB_KeyOfEn" class="easyui-textbox" style="width: 100px" />
                            <input id="CB_Generate_Tags" type="checkbox" checked="checked" /><label for="CB_Generate_Tags">生成标签</label>
                          <input id="TB_UIBindKey" class="easyui-textbox" style="width: 200px; visibility:hidden" />
                          <input id="TB_Vals" class="easyui-textbox" style="width: 200px; visibility:hidden" />
                            
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</body>
</html>
